package com.aya.activity.platform.vip;

import com.aya.activity.core.UserActivity;

import java.math.BigDecimal;

public class Vip implements UserActivity {
    public void setVipService(VipService vipService) {
        this.vipService = vipService;
    }

    VipService vipService;
    @Override
    public <U> BigDecimal activity(U userId, BigDecimal price) {
        Boolean isVip = vipService.selectIsVip(userId);
        if(!isVip){
            return price;
        }
        BigDecimal vipPrice = vipService.selectVipPrice(userId);
        return price.subtract(vipPrice);
    }
}
